package cn.edu.hcnu.mapper;


import cn.edu.hcnu.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("SELECT * FROM user")
    List<User> list();

    @Select("SELECT * FROM user WHERE id=#{id}")
    User queryByID(int id);

    @Insert("INSERT INTO user(name, email, age) VALUES(#{name},#{email},#{age}) ")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertUser(User user);

    @Update("UPDATE user set name=#{name},email=#{email},age=#{age} WHERE id=#{id}")
    int updateUser(User user);

    @Delete("DELETE FROM user WHERE id=#{id}")
    int deleteUser(int id);

    @Select("SELECT * FROM user WHERE name like CONCAT('%',#{name},'%') ")
    List<User> queryLike(String name);
}
